package com.gradle.plugin

import com.gradle.po.User
import com.gradle.tasks.AppInfo
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.GroovyPlugin
import org.gradle.api.plugins.JavaPlugin

class PrintUsernamePlugin implements Plugin<Project> {

    static final String EXTENSION_NAME = 'zyl'

    @Override
    void apply(Project project) {
        project.plugins.apply(GroovyPlugin)
        project.extensions.create(EXTENSION_NAME, User)
        addTasks(project)
        addAppTasks(project)
    }

    void addTasks(Project project) {
    }

    private addAppTasks(Project project) {
        project.task('appInfo', type: AppInfo) {
            println "into addAppTasks"
            conventionMapping.username = { project.extensions.findByName(EXTENSION_NAME).username }

        }
    }
}
